﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using HZ.Supervise.DAL;
using HZ.Supervise.Model;

namespace HZ.Supervise.BLL
{
	public class BLL_PreWarning : HZ.Supervise.IBLL.IBLL_PreWarning
	{

		public System.Data.DataTable GetHospital(string hospitalname, string areaid, int currentpage, int pagesize, out int totalrecord)
		{
			return DAL.DAL_Hospital.GetHospital(hospitalname, areaid, currentpage, pagesize, out totalrecord);
		}

        /// <summary>
        /// 绑定药品
        /// by张雄  2011.5.23
        /// </summary>
        /// <param name="where">where条件</param>
        /// <param name="currentpage">当前页</param>
        /// <param name="pagesize">每页的行数</param>
        /// <param name="totalrecord">参数</param>
        /// <returns></returns>
        public System.Data.DataTable GetHospital1(string where,string whereHos, int currentpage, int pagesize, out int totalrecord)
        {
            return DAL.DAL_Hospital.GetHospital1(where,whereHos, currentpage, pagesize, out totalrecord);
        }

		public DataTable GetCompany(string companyname, int currentpage, int pagesize, out int totalrecord)
		{
			return DAL.DAL_Company.GetCompany(companyname, currentpage, pagesize, out totalrecord);
		}

		public DataTable GetManageOrg(string manageOrgName, int currentpage, int pagesize, out int totalrecord)
		{
			return DAL.DAL_Company.GetManageOrg(manageOrgName, currentpage, pagesize, out totalrecord);
		}

		public int AddDrugPreWarning(HZ.Supervise.Model.DrugPreWarning drugprewarning)
		{
			if (string.IsNullOrEmpty(drugprewarning.DrugPreWarningID))
			{
				drugprewarning.DrugPreWarningID = Guid.NewGuid().ToString();
			}
			return HZ.Data.DbHelperFactory.Create().ExecuteNonQuery(DAL_Helper.GetInsertSql(drugprewarning));
		}

		public int UpdateDrugPreWarning(HZ.Supervise.Model.DrugPreWarning drugprewarning)
		{
			return HZ.Data.DbHelperFactory.Create().ExecuteNonQuery(DAL_Helper.GetUpdateSql(drugprewarning));
		}

		public int DeleteDrugPreWarning(HZ.Supervise.Model.DrugPreWarning drugprewarning)
		{
			return HZ.Data.DbHelperFactory.Create().ExecuteNonQuery(DAL_Helper.GetDeleteSql(drugprewarning));
		}

		public int AddTradePreWarning(HZ.Supervise.Model.TradePreWarning tradeprewarning)
		{
			if (string.IsNullOrEmpty(tradeprewarning.TradePreWarningID))
			{
				tradeprewarning.TradePreWarningID = Guid.NewGuid().ToString();
			}
			return HZ.Data.DbHelperFactory.Create().ExecuteNonQuery(DAL_Helper.GetInsertSql(tradeprewarning));
		}

		public int UpdateTradePreWarning(HZ.Supervise.Model.TradePreWarning tradeprewarning)
		{
			return HZ.Data.DbHelperFactory.Create().ExecuteNonQuery(DAL_Helper.GetUpdateSql(tradeprewarning));
		}

		public int DeleteTradePreWarning(HZ.Supervise.Model.TradePreWarning tradeprewarning)
		{
			return HZ.Data.DbHelperFactory.Create().ExecuteNonQuery(DAL_Helper.GetDeleteSql(tradeprewarning));
		}


		public System.Data.DataTable GetDrugPreWarning(Model.DrugPreWarning drugprewarning, int currentpage, int pagesize, out int totalrecord)
		{

			DataTable dt = DAL.DAL_PreWarning.GetDrugPreWarning(drugprewarning, currentpage, pagesize, out  totalrecord);
			dt.Columns.Add(new DataColumn("AreaName"));
			BLL_Area ba = new BLL_Area();
			foreach (DataRow item in dt.Rows)
			{
				if (!string.IsNullOrEmpty(item["AreaID"].ToString()))
				{
					item["AreaName"] = ba.GetAreaNamesByID(item["AreaID"].ToString());
				}
			}
			return dt;
		}

		public System.Data.DataTable GetTradePreWarning(HZ.Supervise.Model.TradePreWarning tradeprewarning, int currentpage, int pagesize, out int totalrecord)
		{
			DataTable dt = DAL.DAL_PreWarning.GetTradePreWarning(tradeprewarning, currentpage, pagesize, out  totalrecord);
			dt.Columns.Add(new DataColumn("AreaName"));
			BLL_Area ba = new BLL_Area();
			foreach (DataRow item in dt.Rows)
			{
				if (!string.IsNullOrEmpty(item["AreaID"].ToString()))
				{
					item["AreaName"] = ba.GetAreaNamesByID(item["AreaID"].ToString());
				}
			}
			return dt;
		}

		public System.Data.DataTable GetDrugPreWarning_CL(HZ.Supervise.Model.DrugPreWarning drugprewarning, int currentpage, int pagesize, out int totalrecord)
		{
			DataTable dt = DAL.DAL_PreWarning.GetDrugPreWarning_CL(drugprewarning, currentpage, pagesize, out  totalrecord);
			dt.Columns.Add(new DataColumn("AreaName"));
			BLL_Area ba = new BLL_Area();
			foreach (DataRow item in dt.Rows)
			{
				if (!string.IsNullOrEmpty(item["AreaID"].ToString()))
				{
					item["AreaName"] = ba.GetAreaNamesByID(item["AreaID"].ToString());
				}
			}
			return dt;
		}

		public System.Data.DataTable GetTradePreWarning_CL(HZ.Supervise.Model.TradePreWarning tradeprewarning, int currentpage, int pagesize, out int totalrecord)
		{
			DataTable dt = DAL.DAL_PreWarning.GetTradePreWarning_CL(tradeprewarning, currentpage, pagesize, out  totalrecord);
			dt.Columns.Add(new DataColumn("AreaName"));
			BLL_Area ba = new BLL_Area();
			foreach (DataRow item in dt.Rows)
			{
				if (!string.IsNullOrEmpty(item["AreaID"].ToString()))
				{
					item["AreaName"] = ba.GetAreaNamesByID(item["AreaID"].ToString());
				}
			}
			return dt;
		}

		public System.Data.DataTable GetWarningData(HZ.Supervise.Model.WarningData warningData, int currentpage, int pagesize, out int totalrecord)
		{
			DataTable dt = DAL.DAL_PreWarning.GetWarningData(warningData, currentpage, pagesize, out  totalrecord);

			return dt;
		}

		public void Insert_WarningData()
		{
			DAL.DAL_PreWarning.Insert_WarningData();
		}


		public DataTable GetWarningArea()
		{
			return DAL.DAL_PreWarning.GetWarningArea();
		}

		public bool DrugCheckDataSource(HZ.Supervise.Model.DrugPreWarning drug)
		{
			return DAL.DAL_PreWarning.DrugCheckDataSource(drug);
		}

		public bool TranCheckDataSource(HZ.Supervise.Model.TradePreWarning tran)
		{
			return DAL.DAL_PreWarning.TranCheckDataSource(tran);
		}

		public System.Data.DataTable GetHospitalName(string HospitalID, string AreaID, int currentpage, int pagesize, out int totalrecord)
		{
			return DAL.DAL_Hospital.GetHospitalName(HospitalID, AreaID, currentpage, pagesize, out totalrecord);
		}

		public System.Data.DataTable GetHospitalName(string HospitalIDorname, int currentpage, int pagesize, out int totalrecord)
		{
			return DAL.DAL_Hospital.GetHospitalName(HospitalIDorname, currentpage, pagesize, out totalrecord);
		}

		//public System.Data.DataTable GetHospitalName_Type(string HospitalIDorname, string HospitalType, string aid, int currentpage, int pagesize, out int totalrecord)
		//{
		//    return DAL.DAL_Hospital.GetHospitalName_Type(HospitalIDorname,HospitalType,aid,currentpage, pagesize, out totalrecord);
		//}

		public System.Data.DataTable GetHospitalName_Type(string HospitalIDorname, string aid, int currentpage, int pagesize, out int totalrecord)
		{
			return DAL.DAL_Hospital.GetHospitalName_Type(HospitalIDorname, aid, currentpage, pagesize, out totalrecord);
		}

		/// <summary>
		/// 获取医院级别
		/// </summary>
		/// <returns></returns>
		public System.Data.DataTable GetHospitalType()
		{
			return DAL.DAL_Hospital.GetHospitalType();
		}


		/// <summary>
		/// 获得采购医院的数量
		/// </summary>
		/// <param name="num"></param>
		/// <returns></returns>
		public int GetHospitalCount()
		{
			return DAL.DAL_Hospital.GetHospitalCount();
		}
		public int GetGoodsCount()
		{
			return DAL.DAL_Hospital.GetGoodsCount();
		}
		/// <summary>
		/// 返回月排名
		/// </summary>
		/// <param name="_strmonth1">选择月份</param>
		/// <param name="_strmonth2">上月份</param>
		/// <param name="_strorderby">排序字段</param>
		///<param name="strwhere">查询条件</param>
		/// <param name="currentpage"></param>
		/// <param name="pagesize"></param>
		/// <param name="totalrecord"></param>
		/// <returns></returns>
		public DataTable GeteHospsRanking(string Sort, string time1, string time2, string where, string orderby, string dropmode, int currentpage, int pagesize, out int totalrecord)
		{
			return DAL_Hospital.GeteHospsRanking(Sort, time1, time2, where, orderby, dropmode, currentpage, pagesize, out totalrecord);
		}
		/// <summary>
		/// 曹鹏
		/// 2011年5月17日14:03:03 
		/// 医院排名
		/// </summary>
		/// <param name="orderOfRank"></param>
		/// <param name="orderBy"></param>
		/// <param name="wherePm"></param>
		/// <param name="wherePms"></param>
		/// <param name="sortSource"></param>
		/// <param name="currentpage"></param>
		/// <param name="pagesize"></param>
		/// <param name="totalrecord"></param>
		/// <returns></returns>
		public DataTable GeteHospsRanking1(string orderOfRank, string orderBy, string wherePm, string wherePms, string sortSource, string whereHosName, int currentpage, int pagesize, out int totalrecord)
		{

			return DAL_Hospital.GeteHospsRanking1( orderOfRank,  orderBy,  wherePm,  wherePms,  sortSource, whereHosName,  currentpage,  pagesize, out  totalrecord);

		}

		/// <summary>
		/// 返回月排名(按时间段)
		/// </summary>
		/// <param name="_strmonth1">选择月份</param>
		/// <param name="_strmonth2">上月份</param>
		/// <param name="_strorderby">排序字段</param>
		///<param name="strwhere">查询条件</param>
		/// <param name="currentpage"></param>
		/// <param name="pagesize"></param>
		/// <param name="totalrecord"></param>
		/// <returns></returns>
		public DataTable GeteHospsRankingTime(string _strmonth1, string _strorderby, string strwhere1, string strsortsource, int currentpage, int pagesize, out int totalrecord)
		{
			return DAL_Hospital.GeteHospsRankingTime(_strmonth1, _strorderby, strwhere1, strsortsource, currentpage, pagesize, out totalrecord);
		}
		public DataTable GetCompanyName(string companyid, int currentpage, int pagesize, out int totalrecord)
		{
			return DAL.DAL_Company.GetCompanyName(companyid, currentpage, pagesize, out totalrecord);
		}
		public DataTable GetCompanyName(string companyidname, string companytypeid, int currentpage, int pagesize, out int totalrecord)
		{
			return DAL.DAL_Company.GetCompanyName(companyidname, companytypeid, currentpage, pagesize, out totalrecord);
		}
		/// <summary>
		/// 将企业添加到黑名单
		/// </summary>
		/// <param name="blackList"></param>
		/// <returns></returns>
		public int InsertIntoBlackList(HZ.Supervise.Model.BlackList blackList)
		{
			return DAL.DAL_Company.InsertIntoBlackList(blackList);
		}
		/// <summary>
		/// 将投诉添加到投诉表
		/// </summary>
		/// <param name="complain">投诉实体</param>
		/// <returns>0失败 1成功</returns>
		public int InsertIntoComplain(HZ.Supervise.Model.Complain complain)
		{
			return DAL.DAL_Company.InsertIntoComplain(complain);
		}
		/// <summary>
		/// 获取企业详细信息
		/// </summary>
		/// <param name="companyname"></param>
		/// <param name="currentpage"></param>
		/// <param name="pagesize"></param>
		/// <param name="totalrecord"></param>
		/// <returns></returns>
		public DataTable GetCompanyInfo(string companyname, int currentpage, int pagesize, out int totalrecord)
		{
			return DAL.DAL_Company.GetCompanyInfo(companyname, currentpage, pagesize, out totalrecord);
		}
        /// <summary>
		/// 获取企业详细信息
		/// </summary>
		/// <param name="companyname"></param>
		/// <param name="currentpage"></param>
		/// <param name="pagesize"></param>
		/// <param name="totalrecord"></param>
		/// <returns></returns>
        public DataTable GetCompanyInfo(Company com, int currentpage, int pagesize, out int totalrecord)
        {
            return DAL.DAL_Company.GetCompanyInfo(com, currentpage, pagesize, out totalrecord);

        }
		/// <summary>
		/// 获取不再黑名单中的企业
		/// </summary>
		/// <param name="companyname">企业名称</param>
		/// <param name="currentpage">当前页</param>
		/// <param name="pagesize">每页最大数</param>
		/// <param name="totalrecord"></param>
		/// <returns>不在黑名单中的企业</returns>
		public DataTable GetCompanyNotInBlackList(string companyname, int currentpage, int pagesize, out int totalrecord)
		{
			return DAL.DAL_Company.GetCompanyNotInBlackList(companyname, currentpage, pagesize, out totalrecord);
		}
		/// <summary>
		/// 获得黑名单中的企业
		/// </summary>
		/// <param name="companyname">企业名称</param>
		/// <param name="currentpage">当前页</param>
		/// <param name="pagesize">每页显示数据</param>
		/// <param name="totalrecord"></param>
		/// <returns>黑名单中的企业</returns>
		public DataTable GetBlackList(string companyname, int currentpage, int pagesize, out int totalrecord)
		{
			return DAL.DAL_Company.GetBlackList(companyname, currentpage, pagesize, out totalrecord);
		}

		/// <summary>
		/// 获得投诉表中的投诉信息
		/// </summary>
		/// <param name="complain">投诉实体</param>
		/// <param name="currentpage">当前页</param>
		/// <param name="pagesize">每页最大数</param>
		/// <param name="totalrecord"></param>
		/// <returns>投诉信息</returns>
		public DataTable GetComplain(HZ.Supervise.Model.Complain complain, int currentpage, int pagesize, out int totalrecord)
		{
			return DAL.DAL_Company.GetComplain(complain, currentpage, pagesize, out totalrecord);
		}

		/// <summary>
		/// 获得医院
		/// </summary>
		/// <param name="Hospital"></param>
		/// <param name="currentpage"></param>
		/// <param name="pagesize"></param>
		/// <param name="totalrecord"></param>
		/// <returns></returns>
		public DataTable GetHospital(HZ.Supervise.Model.Hospital Hospital, int currentpage, int pagesize, out int totalrecord)
		{
			return DAL.DAL_Company.GetHospital(Hospital, currentpage, pagesize, out totalrecord);
		}
		/// <summary>
		/// 回复投诉
		/// </summary>
		/// <param name="complain"></param>
		/// <returns></returns>
		public int ReplyComplain(HZ.Supervise.Model.Complain complain)
		{
			return DAL.DAL_Company.ReplyComplain(complain);
		}
		/// <summary>
		/// 返回月排名
		/// </summary>
		/// <param name="_strmonth1">选择月份</param>
		/// <param name="_strmonth2">上月份</param>
		/// <param name="_strorderby">排序字段</param>
		///<param name="strwhere">查询条件</param>
		/// <param name="currentpage"></param>
		/// <param name="pagesize"></param>
		/// <param name="totalrecord"></param>
		/// <returns></returns>
		public DataTable GeteCompany_PSRanking(string Sort, string time1, string time2, string where, string orderby, string dropmode, int currentpage, int pagesize, out int totalrecord)
		{
			return DAL_Company.GeteCompany_PSRanking(Sort, time1, time2, where, orderby, dropmode, currentpage, pagesize, out totalrecord);
		}

		/// <summary>
		/// 返回月排名
		/// </summary>
		/// <param name="_strmonth1">选择月份</param>
		/// <param name="_strmonth2">上月份</param>
		/// <param name="_strorderby">排序字段</param>
		///<param name="strwhere">查询条件</param>
		/// <param name="currentpage"></param>
		/// <param name="pagesize"></param>
		/// <param name="totalrecord"></param>
		/// <returns></returns>
		public DataTable GeteCompany_PSRankingTime(string _strmonth1, string _strorderby, string strwhere1, string strsortsource, int currentpage, int pagesize, out int totalrecord)
		{
			return DAL_Company.GeteCompany_PSRankingTime(_strmonth1, _strorderby, strwhere1, strsortsource, currentpage, pagesize, out totalrecord);
		}
	}
}
